import React, { Component } from 'react'
import styles from './list.module.css'
import { withRouter } from 'react-router-dom'
const textobj={
    'yes':'是',
    'no':'否'
}

export class List extends Component {
  render() {
      const {list}=this.props
      console.log(list);
    return (
      <div>
          {list.length?list.map(item=>{
              return <li 
                key={item.id}
                onClick={()=>{
                    console.log(this.props);
                    this.props.history.push('/xiang/' + item.id)
                }}
              >
                  <img src={item.img} alt="" />
                  <p>{item.name}</p>
                  <p>{item.title}</p>
                  <button className={styles[item.text]}>{textobj[item.text]}</button>
              </li>
          }):'暂无数据'}
      </div>
    )
  }
}

export default withRouter(List)